package leetcode.offer;



/**
 * @ClassName T02
 * @Description TODO
 * @Author Fanxc
 * @DATE 2020/11/29 0029 19:51
 * @Version 1.0
 */
public class T04 {
    class Solution {
        /**
         * @Author Fanxc
         * @Description //TODO
         * @Date 2020/11/29 0029 20:33
         * @Param [matrix, target]
         * @return boolean
         **/

        public boolean findNumberIn2DimensionArray(int[][] matrix, int target) {
            int n= matrix.length;
            if (n==0){
                return false;
            }
            int m=matrix[0].length;
            if (m==0){
                return false;
            }
            for (int i = 0; i < n; i++) {
                if (target>=matrix[i][0]&&target<=matrix[i][m-1]){
                    for (int j = 0; j < m; j++) {
                        if (matrix[i][j]==target){
                            return true;
                        }
                    }
                }
            }
            return false;
        }
    }
}
